package com.myprocessing.timer;

public class StepTimer extends Timer {

	private int step;
	private int numOfSteps;
	
	public void trigger() {
		super.trigger();
		step = 1;
		executeAction(timerBegin);
	}
	
	public void update(long currentTime) {
		
		if (step > numOfSteps){
			active = false;
			executeAction(timerEnd);
		}
		
		if (active && (currentTime > begin) && (currentTime >= lastInterval + interval)) {
			step++;
			executeAction(timerInterval);
			lastInterval = currentTime;
		}
		lastCheck = currentTime;
	}

	public int getNumOfSteps() {
		return numOfSteps;
	}

	public void setNumOfSteps(int numOfSteps) {
		this.numOfSteps = numOfSteps;
	}
}
